/**
 * 表单验证
 * 
 * @param {Object} rules 验证字段的规则
 * @param {Object} messages 验证字段的提示信息
 * 
 */

import basic from '../../../xc/model/basic.js';
var actmodel = new basic();
actmodel.do="club_bill"
actmodel.getclubid=function(){
  var actleadgroup =getApp().globalData.actleadgroup
  return actleadgroup.id;
}
//周长收货
actmodel.optool=function(cop,ids){
  if(typeof(ids)=='object'){
    ids= ids.join(",")
  }
  var app = getApp();
  var data = {op:"optool", "cop": cop }
  data["clubid"]=actmodel.getclubid() 
  data["ids"] =ids
  
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/'+actmodel.do,
      'data': data,
      'method': "get",
      success: function (res) {
        if (res.data.errno == 0) {

          resolve(res.data.data);

        }
        reject(res.data.message);
      },
      fail: function (res) {

        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}

actmodel.offset = function (that, reset, para, xcsorts) { 
  if(!xcsorts)
  {
    xcsorts=[["id", "desc"], ["modifytime", "desc"]] ;
  } 
  var acturlpara = {};   
  acturlpara["url"] = "entry/wxapp/"+actmodel.do
  if (para) {
    para["op"] = "offset"
  }
  else
  {
    para={}
  }
  
  para["clubid"]=actmodel.getclubid() 
  return actmodel.pagelist(acturlpara, that, reset, para, xcsorts);
}  
 
actmodel.getmodel=function(ordernum){
  var app = getApp();
  var data = { "op": "getmodel", ordernum: ordernum }
  data["clubid"]=actmodel.getclubid() 

  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/'+actmodel.do,
      'data': data,
      'method': "get",
      success: function (res) {
        if (res.data.errno == 0) {
          resolve(res.data.data);
        }
        reject(res.data.message);
      },
      fail: function (res) {
        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });

}
 

module.exports = actmodel;